import { Component, OnInit } from '@angular/core';
import { NzModalRef, NzMessageService } from 'ng-zorro-antd';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { OrderService } from '@core/routes-services/order.service';
import { RECORD_TYPE_OPTION } from '../../../../constant/dictionary';
import { IntegralRecordService } from '@core/routes-services/integral-record.service';

@Component({
  selector: 'app-company-integral-view',
  templateUrl: './integral-view.component.html',
  styles:[`
    h2{
      border-bottom: 1px solid #1890ff;
      color: #1890ff;
      padding-top: 10px;
    }
  `]
})
export class CompanyIntegralViewComponent implements OnInit {
  entity: any = {};
  isLoading: boolean = false;
  recordTypeOption:any [] = RECORD_TYPE_OPTION

  entityInfo:any = {};

  constructor(private fb: FormBuilder,
              private modal: NzModalRef,
              private integralRecordService: IntegralRecordService,
              public message: NzMessageService,
  ) {
  }

  ngOnInit(): void {
    this.initEntity();
  }

  initEntity() {
    this.isLoading = true;
    this.integralRecordService.detail(this.entity.id).then((res) => {
      console.log(res);
      console.log(this.entity);
      if (res.status.toString().startsWith('20')) {
        this.entityInfo = res.data;
      } else {
        this.message.warning(res.message);
      }
      this.isLoading = false;
    }, error => {
      this.message.error(error.message ? error.message : error.error);
      this.isLoading = false;
    });
  }

  close() {
    this.modal.destroy();
  }
}
